package com.lingnan.tijian.controller;

import com.lingnan.tijian.domain.Orders;
import com.lingnan.tijian.domain.Users;
import com.lingnan.tijian.dto.ApiResponse;
import com.lingnan.tijian.service.ifac.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class OrdersController {
    @Autowired
    OrdersService ordersService;
    @RequestMapping("saveOrders")
    public ApiResponse saveOrders(@RequestBody Orders orders,HttpServletRequest request){
      Users user=(Users)request.getAttribute("user");

      orders.setUserId(user.getUserId());
        return null;
    }

    @RequestMapping("listOrdersByUserIdAndState")
    public ApiResponse listOrdersByUserIdAndState(@RequestBody Orders orders){
            return ordersService.listOrdersByUserIdAndState(orders);
    }
}
